How to install the necessary software

Python3

Check which Python3 version is installed on your machine. Any version $\ge$ 3.7 is ok.

See details here: https://phoenixnap.com/kb/how-to-install-python-3-ubuntu

Troublefree way to install Python3: throught Anaconda

In [ ]:
!python3 --version
# sudo apt-get install python3 python3-distutils python3-apt python3-dev build-essential libssl-dev libffi-dev libxml2-dev libxstl1.dev zlib1g-dev

PIP (Package Installer for Python)

See details here: https://pip.pypa.io/en/stable/installing/

In [ ]:
!curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
!python3 get-pip.py

Jupyter (notebook)

In [ ]:
!python3 -m pip install notebook
# avvia con 
# ~/.local/bin/jupyter notebook

IBM Qiskit

Qiskit is an open source SDK for working with quantum computers at the level of pulses, circuits and algorithms.

See installation details here: https://qiskit.org/documentation/install.html

In [ ]:
!python3 -m pip install qiskit[visualization] --upgrade

Check your installation

In [1]:
%matplotlib inline
from qiskit.circuit.random import random_circuit
random_circuit(4, 4).draw(output='mpl')
Out[1]:
In [ ]:
!python3 -m pip install plotly==4.10.0
!python3 -m pip install "notebook>=5.3" "ipywidgets>=7.2"
!python3 -m pip install kaleido --user
!python3 -m pip install kaleidoscope --user
In [1]:
import numpy as np
import kaleidoscope.qiskit
from kaleidoscope import qsphere

state = np.array([1/np.sqrt(2), 0, 0, 0, 0, 0, 0, 1/np.sqrt(2)])
qsphere(state)

# no worries about error:
# parallel.py:363: NumbaWarning: The TBB threading layer requires TBB version 2019.5 or later i.e., TBB_INTERFACE_VERSION >= 11005. Found TBB_INTERFACE_VERSION = 11004. The TBB threading layer is disabled.
/home/incud/.local/lib/python3.7/site-packages/numba/np/ufunc/parallel.py:363: NumbaWarning: The TBB threading layer requires TBB version 2019.5 or later i.e., TBB_INTERFACE_VERSION >= 11005. Found TBB_INTERFACE_VERSION = 11004. The TBB threading layer is disabled.
  warnings.warn(problem)
/home/incud/anaconda3/lib/python3.7/site-packages/qiskit/providers/ibmq/ibmqfactory.py:192: UserWarning:

Timestamps in IBMQ backend properties, jobs, and job results are all now in local time instead of UTC.

Xanadu Pennylane

A cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.

See installation details here: https://pennylane.ai/install.html

In [ ]:
!python3 -m pip install pennylane --upgrade
In [ ]:
!python3 -m pip install pennylane-qiskit
In [ ]:
!python3 -m pip install autograd

Check your installation

In [2]:
import pennylane as qml
from pennylane import numpy as np # it is important to **always import NumPy from PennyLane**, not the standard NumPy!

dev1 = qml.device("default.qubit", wires=1)

@qml.qnode(dev1)
def circuit(params):
    qml.RX(params[0], wires=0)
    qml.RY(params[1], wires=0)
    return qml.expval(qml.PauliZ(0))

print(circuit([0.54, 0.12]))
0.8515405859048366